import { createRouter, createWebHistory } from "vue-router"

import loginvue from '@/views/login.vue'
import managerhome from "@/views/managerhome.vue"
import Shicimanager from "@/views/manager/shicimanager.vue";
import Authormanager from "@/views/manager/authormanager.vue";
import Activemanager from "@/views/manager/activemanager.vue";
import Mainpost from "@/views/manager/mainpost.vue";
import Usermanager from "@/views/manager/usermanager.vue";
import Userinfo from "@/views/user/userinfo.vue";
import Repassword from "@/views/user/repassword.vue";
import Sectionmanager from "@/views/manager/sectionmanager.vue";
import Replypost from "@/views/manager/replypost.vue";
import Home from "@/views/home.vue";
import Layout from "@/page/index/index.vue"
import Today from "@/views/page/today.vue"
import Speak from "@/views/page/speak.vue";
import Active from "@/views/page/active.vue"
import post from "@/views/page/post.vue";
import Views from "@/views/page/views.vue";
import Userinfos from "@/views/page/userinfo.vue";
import Create from "@/views/page/create.vue";
import Authors from "@/views/page/author.vue";
import sendemail from "@/views/user/sendemail.vue";

const routes = [
  {
    path: '/manager', component: managerhome, redirect: '/info/shicimg',
    children: [
      {
        path: '/info/shicimg', component: Shicimanager,
        meta: {
          roles: ['管理员']
        }
      },
      {
        path: '/info/authormg', component: Authormanager,
        meta: {
          roles: ['管理员']
        }
      },
      {
        path: '/info/activemg', component: Activemanager,
        meta: {
          roles: ['管理员']
        }
      },
      {
        path: '/info/mainpostmg', component: Mainpost,
        meta: {
          roles: ['管理员']
        }
      },
      {
        path: '/user/userinfo', component: Userinfo,
        meta: {
          roles: ['管理员']
        }
      },
      {
        path: '/user/repassword', component: Repassword, meta: {
          roles: ['管理员']
        }
      },
      {
        path: '/info/usermg', component: Usermanager, meta: {
          roles: ['管理员']
        }
      },
      {
        path: '/info/sectionmg', component: Sectionmanager, meta: {
          roles: ['管理员']
        }
      },
      {
        path: '/info/replypostmg', component: Replypost, meta: {
          roles: ['管理员']
        }
      }
    ],
    meta: {
      roles: ['管理员']
    }
  },
  { path: '/login', component: loginvue },
  { path: '/repassword', component: sendemail},
  {
    path: '/home', component: Layout, redirect: '/home/index',
    children: [
      { path: 'index', component: Home ,meta: {
        roles: ['普通用户','作者']
      }},
      { path: 'today', component: Today ,meta: {
        roles: ['普通用户','作者']
      }},
      { path: 'speak', component: Speak ,meta: {
        roles: ['普通用户','作者']
      }},
      { path: 'active', component: Active ,meta: {
        roles: ['普通用户','作者']
      }},
      { path: 'post/:mid', component: post ,meta: {
        roles: ['普通用户','作者']
      }},
      { path: 'view', component: Views ,meta: {
        roles: ['普通用户','作者']
      }},
      { path: 'userinfo', component: Userinfos ,meta: {
        roles: ['普通用户','作者']
      }},
      { path: 'create', component: Create ,meta: {
        roles: ['普通用户','作者']
      }},
      { path: 'author', component: Authors ,meta: {
        roles: ['普通用户','作者']
      }},
    ],
    meta: {
      roles: ['普通用户','作者']
    }
  },


]

const router = createRouter({
  history: createWebHistory(),
  routes: routes
});


export default router